package com.example.jdbc_demo.mapper;

import com.example.jdbc_demo.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    //查询用户信息
    @Select("select * from user where id = #{id}")
    public User getUser(int id);

    //根据用户名查询用户信息
    @Select("select * from user where username=#{username}")
    public List<User> getUserByUsername(String username);

    //用limit和offset实现分段查询，limit表示每页显示多少条，offset表示从第几条开始查
    @Select("select * from user limit #{limit} offset #{offset}")
    public List<User> getUserByPage1(int limit,int offset);

    @Select("select * from user limit #{start},#{size}")
    public List<User> getUserByPage(int start,int size);
}
